﻿<%@ Page Title="" Language="C#" MasterPageFile="~/EasyUI.Master" AutoEventWireup="true" CodeBehind="Listpic.aspx.cs" Inherits="cebao.Web.weatherinfo.Listpic" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">

     <style type="text/css">	
         .fite {
             margin-left:4px;
         }
         .fite label {
             width:100px;
             float:left;
             line-height:35px;
         }
	</style>
    
    <script type="text/javascript">
        var sprovince = "";
        var scity = "";
        var scounty = "";
        var level;
        $.extend($.fn.tree.methods, {
            getLevel: function (jq, target) {
                var l = $(target).parentsUntil("ul.tree", "ul");
                return l.length + 1;
            }
        });
        var pt;
        var uid = "";
        var map;
        var data_info;
        var opts;
        $(function () {
            $.ajax({
                type: "post",
                dataType: "json",
                url: "../admin/getinfo.ashx?action=level",
                success: function aa(data) {
                    level = data[0].level;
                    if (level == -1) level = 3;
                    if (level <= 3)
                        sprovince = data[0].province;
                    if (level <= 2)
                        scity = data[0].city;
                    if (level <= 1)
                        scounty = data[0].county;

                }
            });

            InitTree();
            InitSearch();
            InitGird();


        });

        function getQueryParams(queryParams) {
            queryParams.uprovince = sprovince;
            queryParams.ucity = scity;
            queryParams.ucounty = scounty;
            return queryParams;

        }
        //增加查询参数，重新加载表格  
        function reloadgrid() {
            var queryParams = $('#tt').datagrid('options').queryParams;
            getQueryParams(queryParams);
            $('#tt').datagrid('options').queryParams = queryParams;
            $("#tt").datagrid('reload');
        }

        //初始化表格
        function InitGird() {
            $('#tt').datagrid({
                title: '测报灯设备用户列表', //表格标题
                url: 'GetWeather.ashx', //请求数据的页面
                sortName: 'UserName', //排序字段
                idField: 'KeyId', //标识字段,主键
                iconCls: '', //标题左边的图标
                width: '95%', //宽度
                height: '95%', //高度
                nowrap: false, //是否换行，True 就会把数据显示在一行里
                striped: true, //True 奇偶行使用不同背景色
                collapsible: false, //可折叠
                sortOrder: 'desc', //排序类型
                remoteSort: true, //定义是否从服务器给数据排序
                fitColumns: true,
                singleSelect: true,
                method: 'post',
                columns: [[
	                { title: '用户名', field: 'UserName', width: 80, sortable: true },
                    { title: '真实姓名', field: 'TrueName', width: 120, sortable: true },
                    { title: '手机', field: 'Mobile', width: 80 },
                    { title: 'QQ', field: 'QQ', width: 80 },
                    { title: '地址', field: 'madd', width: 220 },
                    {
                        title: '查看设备', field: 'v', width: 80, formatter: function (v, d, i) {
                            return '<a href="#" onclick="top.addTab(\'图像监测' + d.UserName + '\',\'weatherinfo/Listpiccb.aspx?uid=' + d.KeyId + '\', \'icon icon-server\');">图像监测</a>';
                            //return '<a href="#" onclick="top.addTab(\'图像监测' + d.UserName + '\',\'' + qxurl + '/status_pic/PICN.aspx?uid=' + d.KeyId + '&navid=45\', \'icon icon-server\');">图像监测</a>';
                        }
                    }
                ]],
                toolbar: "#tab_toolbar",
                queryParams: { "action": "querypic" },
                pageNumber: 1, //默认索引页
                pageSize: 200, //默认一页数据条数
                rownumbers: true, //行号
                pageList: [10, 20, 50, 200, 500],
                pagination: true
            });
        }

        function InitSearch() {
            $("#ipt_search").searchbox({
                width: 140,
                searcher: function (val, name) {
                    var queryParams = $('#tt').datagrid('options').queryParams;
                    getQueryParams(queryParams);
                    $('#tt').datagrid('options').queryParams = queryParams;
                    $('#tt').datagrid('options').queryParams.search_type = name;
                    $('#tt').datagrid('options').queryParams.search_value = val;
                    $('#tt').datagrid('reload');
                },
                prompt: '查询信息'
            });
        }
        function InitTree() {
            $('#pt').tree({
                width: '100%', //宽度                
                lines: true,
                //data: provincetree,   
                url: '../areainfo/GetArea.ashx', //请求数据的页面 
                method: 'post',
                queryParams: { "action": "querymyareauser" },
                onBeforeExpand: function (node) {
                    $("#pt").tree("options").queryParams = { "action": "queryyb9" };
                    $('#pt').tree('options').url = "../areainfo/GetArea.ashx?pid=" + node.id;
                },
                onClick: function (node) {
                    sprovince = scity = scounty = "";
                    if (node.text != "") {
                        var lv = $('#pt').tree("getLevel", node.target);
                        if (lv == 2) {
                            if (level > 3)
                                sprovince = node.text;
                            else if (level == 3)
                                scity = node.text;
                            else if (level == 2)
                                scounty = node.text;
                        }
                        else if (lv == 3) {
                            if (level > 3) {
                                scity = node.text;
                                sprovince = $('#pt').tree("getParent", node.target).text;
                            }
                            else if (level == 3) {
                                scounty = node.text
                                scity = $('#pt').tree("getParent", node.target).text;;
                            }
                        }
                        else if (lv == 4) {
                            if (level > 3) {
                                scounty = node.text;
                                var node1 = $('#pt').tree("getParent", node.target)
                                scity = node1.text;
                                sprovince = $('#pt').tree("getParent", node1.target).text;
                            }
                        }
                        reloadgrid();
                    }
                },
                onLoadSuccess: function (node, param) {
                    //reloadgrid();
                }
            });

        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div class="easyui-layout" style="width: 100%; height: 100%;" id="mycon">
       <div region="west" split="true" title="区域检索" style="width: 180px;overflow:scroll" id="west">
            <ul id="pt"></ul>
        </div>
        <div region="center" style="background: #eee; overflow: auto">             
                 <table id="tt"></table>       
        </div>
    </div>
    
        <div id="tab_toolbar" style="padding: 4px;">
            <table cellpadding="0" cellspacing="0" style="width: 100%">
                <tr>
                    <td style="text-align: right; padding-right: 15px">                       

                        <input id="ipt_search" menu="#search_menu" />
                        <div id="search_menu" style="width: 80px">
                            <div name="usernum">
                                用户名
                            </div>
                            <div name="username">
                                姓 名
                            </div>
                        </div>
                    </td>
                </tr>
            </table>

        </div>  
 
</asp:Content>
